package com.da.lon.wang.xlg.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.da.lon.wang.xlg.R;
import com.da.lon.wang.xlg.bean.HomeResultBean.HomeItemContentBean;

import java.util.ArrayList;

public class HomeCatgroItemAdapter extends BaseAdapter {

    HolderCatergHead holder;
    private LayoutInflater inflater;
    private Context context;
    private ArrayList<HomeItemContentBean> proDatas;

    public HomeCatgroItemAdapter(Context context,
                                 ArrayList<HomeItemContentBean> proDatas) {
        this.context = context;
        this.proDatas = proDatas;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return proDatas == null ? 0 : proDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        // 活动页面列表项
        try {
            if (convertView == null) {
                holder = new HolderCatergHead();
                convertView = inflater.inflate(R.layout.ocoffee_home_model1,
                        null);
                holder.home_model1_tv = (TextView) convertView
                        .findViewById(R.id.home_model1_tv);
                convertView.setTag(holder);
            } else {
                holder = (HolderCatergHead) convertView.getTag();
            }
            if (position == 0) {
                holder.home_model1_tv.setTextColor(Color.parseColor("#ec504e"));
            }
            holder.home_model1_tv.setText(proDatas.get(position).getName());

        } catch (Exception e) {
            e.printStackTrace();
        }

        return convertView;
    }
}

class HolderCatergHead {

    public TextView home_model1_tv;
}
